package cn.sdhuijin.controller;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.sdhuijin.service.DeductionService;
import cn.sdhuijin.utils.CommonUtil;

/**
 * @author sunp@sdhuijin.cn:
 * @version 创建时间：2015年5月11日 下午4:57:01 类说明
 */
@Controller
public class DeductionController {

	@Inject
	private DeductionService deductionService;

	@RequestMapping(value = { "/deductionsave" }, method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> saveDeduction(@RequestParam("items") String items)
			throws Exception {
		List<LinkedHashMap<String, Object>> deductions = CommonUtil
				.readJson2List(items);
		deductionService.BatchSave(deductions);
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("success", true);
		return result;
	}

}
